/*
	单选
*/
define(
	[
		'require',
		'broada/base/text!./template.hbs'
	],
	function (require) {
		"use strict";

		var forEach = Ember.EnumerableUtils.forEach;
		var tpl = require('broada/base/text!./template.hbs');

		var ServiceRadioView = Ember.Component.extend({
			layout: Ember.HTMLBars.compile(tpl),	
			didInsertElement: function(){
				var ctrl = this.get("controller"),
					view = this,
					showOrhide = this.get("showOrhide"),
					dimensionNum = this.get("dimensionNum"),
					value = this.get("value");

				var $viewRoot = view.$();

				$viewRoot.find("input").click(function(){
					var serverity = $(this).attr("value");
					ctrl.sendAction("itemClick",serverity);
				});

				if(showOrhide.length == 5){
					Ember.A(showOrhide).forEach(function(node){
						var string = '.'+node+dimensionNum;
						$viewRoot.find(string).show();
					});

					showOrhide = ["typeName"];
				}

				Ember.A(showOrhide).forEach(function(node){
					var string = '.'+node+dimensionNum,
						key = null;
					$viewRoot.find(string).hide();
					var stringValue = null;

					stringValue = value[node];

					if(node == "typeName"){
						key = "交易类型";
					}else if(node == "channelName"){
						key = "交易渠道";
					}else if(node == "responseCode"){
						key = "交易返回码" ;
					}else if(node == "dstIp"){
						key = "服务器IP";
					}else if(node == "srcIp"){
						key = "客户端IP";
					}

					$(".dimension-radio-fs-wrapper").eq(dimensionNum-1).append("<div class='control-group pull-left' style='padding-left:30px'><span class='pull-left dimension-radio-fs dimension-radio-fc'>"+key+":</span><span class='pull-left dimension-radio-fs  dimension-radio-mr10 dimension-radio-fc'>"+stringValue+"</span></div>")
					// $viewRoot.find(string).parent().prepend("<div class='control-group pull-left'><span class='pull-left dimension-radio-fs dimension-radio-fc'>"+key+":</span><span class='pull-left dimension-radio-fs  dimension-radio-mr10 dimension-radio-fc'>"+stringValue+"</span></div>")
				});
				

			}
		});

		APM.ui.ServiceRadioView = ServiceRadioView;

		return ServiceRadioView;
	}
);